
package managedbean.CRM.Customer;

import entity.CRM.LineItem;
import entity.CRM.SaleOrder;
import entity.CRM.Customer;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import session.stateless.CRM.SaleOrderBeanLocal;

@ManagedBean(name="viewCustomersSaleOrders")
@ViewScoped
public class ViewCustomersSaleOrdersManagerBean implements Serializable{

    public ViewCustomersSaleOrdersManagerBean() {
    }
    
    @EJB
    private SaleOrderBeanLocal saleOrderBeanLocal;
    private Customer selectedCustomer;
    private List<SaleOrder> selectedSaleOrders;
    private List<LineItem> lineItems;
    private String statusMessage;
    
    public void initView(PhaseEvent event)
    {
        selectedCustomer = (Customer)FacesContext.getCurrentInstance().getExternalContext().getFlash().get("selectedCustomer");            
        selectedSaleOrders = saleOrderBeanLocal.getSaleOrdersByCustomer(selectedCustomer.getRegistrationNumber());
        System.out.println("initView"+selectedSaleOrders.size());
    }

    public Customer getSelectedCustomer() {
        return selectedCustomer;
    }

    public void setSelectedCustomer(Customer selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    public SaleOrderBeanLocal getSaleOrderBeanLocal() {
        return saleOrderBeanLocal;
    }

    public void setSaleOrderBeanLocal(SaleOrderBeanLocal saleOrderBeanLocal) {
        this.saleOrderBeanLocal = saleOrderBeanLocal;
    }

    public List<SaleOrder> getSelectedSaleOrders() {
        return selectedSaleOrders;
    }

    public void setSelectedSaleOrders(List<SaleOrder> selectedSaleOrders) {
        this.selectedSaleOrders = selectedSaleOrders;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }

    public List<LineItem> getLineItems() {
        return lineItems;
    }

    public void setLineItems(List<LineItem> lineItems) {
        this.lineItems = lineItems;
    }
    
    public List<SaleOrder> getSaleOrder(){
        return saleOrderBeanLocal.getSaleOrders();
    }

}